{% extends "base.html" %}
  {% block content %}
    {% from "forms/macros.html" import render_field_busqueda %}
     <SCRIPT LANGUAGE="JavaScript">
	
		url_1 = "/solicitud/modificar/ID/"
		url_2 = "/solicitud/eliminar/ID/"
		url_3 = "/solicitud/consultar/ID/"
		url_4 = "/solicitud/enviar/ID/"
		
		
		id_href_1 = 'modificar'
		id_href_2 = 'eliminar'
		id_href_3 = 'consultar'
		id_href_4 = 'enviar'
		
 
		function obtener_id(id) {
        	link_1 = document.getElementById(id_href_1)
        	link_2 = document.getElementById(id_href_2)
        	link_3 = document.getElementById(id_href_3)
        	link_4 = document.getElementById(id_href_4)
        	
        	new_url_1 = url_1.replace('ID', id)
        	new_url_2 = url_2.replace('ID', id)
        	new_url_3 = url_3.replace('ID', id)
        	new_url_4 = url_4.replace('ID', id)
        	
        	link_1.href = new_url_1
        	link_2.href = new_url_2
        	link_3.href = new_url_3
        	link_4.href = new_url_4
        	
        
		}
		
		function pregunta(){
    		if(confirm('Esta seguro de que desea eliminar la solicitud?')){
    			return true;
    		}else{
    			return false;
    		}
    	}
    	
    	function pregunta_enviar(){
    		if(confirm('Esta seguro de que desea enviar la solicitud?')){
    			return true;
    		}else{
    			return false;
    		}
    	}
   
    
    </SCRIPT>
    <h2> Administracion de Solicitudes de Cambio </h2>
    <form method="POST" action={{ url_for('solicitudes.administracion_solicitud') }} class="form">
   		{{ form.csrf_token }} 	
   <div style="overflow:auto; width: 770px; height: 550px;" > 
   	 <table " > 
     	 <tr >
     	 	 <th></th>
  			 <th>  <label>Filtros</label> </th>
  			 <th>{{ render_field_busqueda(form.observacion, class="input text") }}</th> 
  			 <th>{{ render_field_busqueda(form.estado, class="input text") }}</th> 
     		 <th>{{ render_field_busqueda(form.impacto_total, class="input text") }}</th>
     		 <th>{{ render_field_busqueda(form.costo_total, class="input text", readonly=true) }}</th>    		
      	</tr >  			
  		<tr >
 			<th></th>
  			<th> <center>ID </center></th>
  			<th> <center> OBSERVACION <c/enter></td>
  			<th> <center> ESTADO <c/enter></td>
      		<th> <center> IMPACTO TOTAL <c/enter></td>
      		<th> <center> COSTO TOTAL <c/enter></td>    		
      		
      	</tr >  		
		{% for solicitud in solicitudes %}			
   				<tr >
   				  <th><input type = "radio" name = "seleccionado" id="select" onchange="obtener_id({{solicitud.id}})"></th>
      			  <td> <center>{{ solicitud.id }} </center></td> 
      			  <td> <center>{{ solicitud.observacion}} <center></td>
      			  <td> <center>{{ solicitud.estado }} <center></td>     			  
      			  <td> <center>{{ solicitud.impacto_total }} <center></td>
      			  <td> <center>{{ solicitud.costo_total }} <center></td>     			
   				</tr>  		 	
		{% endfor %}				
		
	</table> 
	</div> 
		 <div class="buttons">
                <button type="submit" class="button green">Buscar</button>
                <button type="submit" class="button green"> 
                	<a href="{{ url_for('solicitudes.crear_solicitud') }}">Crear</a>
       			</button>
       			 <button type="submit" class="button green">
               		 <a href="" id="modificar">Modificar</a>
        		</button>
        		<button type="submit" class="button green">
                		<a href="" id="consultar">Consultar</a>
        		</button>
        		<button type="submit"  onclick =  "return pregunta()">
        			<a href="" id="eliminar">Eliminar</a>
        		</button>
        		<button type="submit"  onclick =  "return pregunta_enviar()">
        			<a href="" id="enviar">Enviar</a>
        		</button>
                <button type="submit" class="button green">
                		<a href="{{ url_for('solicitudes.ver_solicitudes_comite') }}">Ver Solicitudes</a>
        		</button>	
        		
    	</div>  
   
    </form>    
  {% endblock %}